<?php

	$url = 'http://od.qumei.com/%E5%BE%AE%E4%BF%A1web%E7%94%9F%E6%80%81/sgb/html/wxapi.php';

	switch ($_GET['type']) {

		case 'jsapi':

			$parmas = ['type'=>'jsapi','ht'=>$_GET['ht']];

		    echo php_do_Url_GET($url,$parmas);

			break;

		case 'get_authorization_code':  //使用code调取用户信息

			$parmas = ['type'=>'authorization_code','code'=>$_GET['code']];


	   		echo php_do_Url_GET($url,$parmas);

			break;

		case 'getuserInfo_refresh_token': //使用热刷新调取用户信息

			$parmas = ['type'=>'refresh_token','refresh_token'=>$_GET['refresh_token']];

		    echo php_do_Url_GET($url,$parmas);

			break;
		
		default:
			echo '参数传递有误云托管界面';
			break;
	}


    


	function php_do_Url_GET($url,$params=[],$headers=[]){ //Get get

		$url = "{$url}?" . http_build_query ($params);
		// echo $url;
		$ch = curl_init ();
		curl_setopt ( $ch, CURLOPT_URL, $url );
		curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
		curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
		curl_setopt ( $ch, CURLOPT_TIMEOUT, 60 );
		//curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params );
		curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_SSLVERSION, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


		$json_string = curl_exec ( $ch );

		return $json_string;

		// $data = json_decode($json_string, true);

		// curl_close ( $ch );

		// return $data;
	}

?>
